package com.vm.common;

/**
 * 得到网站用户的根目录
 * 
 * @author thomas
 */
public class WebRootPath {
	
	private static String rootPath;
	
	public static String getRootPath() {
		return rootPath;
	}
	
	public static void setRootPathf(String path) {
		rootPath = path;
	}
	
	public static void reLoad() {
		init();
	}
	
	static {
		init();
	}
	
	 
	private static void init() {
		String path = WebRootPath.class.getResource("/").getPath();
		
		if (path != null) {
			if (path.indexOf("WEB-INF/") != -1) {
				path = path.substring(0, path.indexOf("WEB-INF/"));
			}
		} else {
			path = System.getProperty("user.dir") + "/";
		}
		
		rootPath = path;
		
	}
}
